using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
	[Table("Subscription", "", "Wicresoft.Messages.ConnectionString")]
	public class Subscription : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_SUBSCRIPTIONID = "SubscriptionID";
		public const string SQLCOL_USERNAME = "UserName";
		public const string SQLCOL_MODULEID = "ModuleID";
		public const string SQLCOL_SUBSCRIPTIONDEVICES = "SubscriptionDevices";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Subscription () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Subscription (Guid SubscriptionID)
		{
			this.SubscriptionID = SubscriptionID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			SubscriptionID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_SUBSCRIPTIONID]);
			UserName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_USERNAME]);
			ModuleID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MODULEID]);
			SubscriptionDevices = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_SUBSCRIPTIONDEVICES]);
		}

		#region Properties 
		#region Property <Guid> SubscriptionID
		[Property("SubscriptionID", 16, SqlDbType.UniqueIdentifier, false, true)]
		public Guid SubscriptionID 
		{
			get { return _SubscriptionID; }
			set { _SubscriptionID = value; }
		}
		private Guid _SubscriptionID = Guid.Empty;
		#endregion

		#region Property <string> UserName
		[Property("UserName", 100, SqlDbType.NVarChar, false, false)]
		public string UserName 
		{
			get { return _UserName; }
			set { _UserName = value; }
		}
		private string _UserName = null;
		#endregion

		#region Property <Guid> ModuleID
		[Property("ModuleID", 16, SqlDbType.UniqueIdentifier, false, false)]
		public Guid ModuleID 
		{
			get { return _ModuleID; }
			set { _ModuleID = value; }
		}
		private Guid _ModuleID = Guid.Empty;
		#endregion

		#region Property <int> SubscriptionDevices
		[Property("SubscriptionDevices", 4, SqlDbType.Int, false, false)]
		public int SubscriptionDevices 
		{
			get { return _SubscriptionDevices; }
			set { _SubscriptionDevices = value; }
		}
		private int _SubscriptionDevices = int.MinValue;
		#endregion
		#endregion




	}
}
